package com.tanhua.manager.controller;

import com.tanhua.manager.service.UserVideoService;
import com.tanhua.manager.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("manage/videos")
public class VideoController {

    @Autowired
    private UserVideoService userVideoService;


    /**
     * 视频记录翻页
     * @param page
     * @param pagesize
     * @param uid
     * @param sortProp
     * @param sortOrder
     * @return
     */
    @GetMapping
    public ResponseEntity<PageResult> UserPagesList(@RequestParam(value = "page", defaultValue = "1") Integer page,
                                                    @RequestParam(value = "pagesize", defaultValue = "10") Integer pagesize,
                                                    @RequestParam("uid") String uid,
                                                    @RequestParam("sortProp") String sortProp,
                                                    @RequestParam("sortOrder") String sortOrder){
        try {
            PageResult pageResult = this.userVideoService.videoList(page, pagesize, uid, sortProp, sortOrder);
            return ResponseEntity.ok(pageResult);
        }catch (Exception e){
            e.printStackTrace();
        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
    }
}
